<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增库存盘点')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-kucunpandianTest-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">商品名称：</label>
                <div class="col-sm-8">
                    <input id="input4name" onchange="dataSet(this.value)" name="goodName" class="form-control" type="text" list="kucunSelect" required>
                    <datalist id="kucunSelect" th:with="type=${@shangpinxinxiMapper.selectShangpinxinxiList(null)}">
                        <option  th:each="lists : ${type}"
                                 th:text="${lists.getShangpinName()}"
                                 th:value="${lists.getShangpinName()+' | '+lists.getShangpinLeibie()+' | '+lists.getGuiGeKuan()+'*'+lists.getGuiGeGao()+'@'+lists.getKaiXiang()}">
                        </option>
                    </datalist>
                    <script type="text/javascript">
                        function dataSet(value) {
                            var str = value.split(" | ")[2].split("@")[0]
                            var kuan = str.split("*")[0]
                            var gao = str.split("*")[1]
                            var kaixiang = value.split("@")[1]
                            var leibie = document.getElementById("leibieSet")
                            if (kuan==="null"){
                                kuan = ""
                            }else {
                                leibie.hidden = false
                            }
                            if (gao==="null") {gao = "";leibie.hidden = true}
                            if (kaixiang==="null" || kaixiang === null) kaixiang = ""
                            document.getElementById("guiGeKuan").value = kuan
                            document.getElementById("guiGeGao").value = gao
                            document.getElementById("kaiXiang").value = kaixiang
                            document.getElementById("input4name").value = value.split(" | ")[0]
                            document.getElementById("leibie2shangpin").value = value.split(" | ")[1]
                        }
                    </script>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">商品类别：</label>
                <div class="col-sm-8">
                    <input id="leibie2shangpin" name="shangpinLeibie" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">库存数量：</label>
                <div class="col-sm-8">
                    <input name="kuncun" class="form-control" type="text" required>
                </div>
            </div>
            <div id="leibieSet">
                <div class="form-group">
                    <label class="col-sm-3 control-label">规格宽：</label>
                    <div class="col-sm-8">
                        <input id="guiGeKuan" name="shangpinGuigeKuan" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">规格高：</label>
                    <div class="col-sm-8">
                        <input id="guiGeGao" name="shangpinGuigeGao" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">开向：</label>
                    <div class="col-sm-8">
                        <input id="kaiXiang" name="shangpinKaixiang" class="form-control" type="text" list="kxAll">
                        <datalist id="kxAll" th:with="type=${@shangpinxinxiMapper.selectKaixiang()}">
                            <option th:each="lists : ${type}"
                                    th:text="${lists}"
                                    th:value="${lists}"></option>
                        </datalist>
                    </div>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "kucunpandian/kucunpandianTest"
        $("#form-kucunpandianTest-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-kucunpandianTest-add').serialize());
            }
        }

        $(".file-upload").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    </script>
</body>
</html>